package com.design.singleton;

/**
 * 懒汉模式（线程安全）
 * @author ytj
 * @date 2024/11/27 15:30
 */
public class Singleton2 {

    private static Singleton2 singleton2;

    private Singleton2(){}

    public static synchronized Singleton2 getSingleton2(){
        if(singleton2==null){
            return new Singleton2();
        }
        return singleton2;
    }
}
